<div class="easyui-layout" data-options="fit:true">
    <div data-options="region:'north'" class="center">
        <div class="webmap">
            <p class="webmaptip">当前位置:</p>
            <a href="javascript:;" class="easyui-link" data-options="plain:true">奖励管理</a>
            <p class="webmaptip">></p>
            <a href="javascript:;" class="easyui-link" data-options="plain:true">用户奖励</a>
        </div>
        <div class="querybycon">
            <form id="query">
                <div class="queryinfo">
                    <div>用户ID<input type="text" name="userId"></div>
                    <div>使用状态<input class="easyui-combobox" name="state"
                                    data-options="url:'/dictionary/userBonusState?all=true'">
                    </div>
                    <div class="query">
                        <a id="querybtn" href="javascript:;" class="easyui-linkbutton  "
                           data-options="iconCls:'fa fa-search'"></a>
                    </div>
                </div>
            </form>
        </div>

    </div>
    <div data-options="region:'center'" class="center">
        <table id="list"></table>
    </div>
</div>

<script type="text/javascript">
    var edit = "/userBonus/edit"
    var addUrl = "/page/bonus/userbonusadd.html";
    var editUrl = "/page/bonus/userbonusedit.html";
    var save = '/userBonus/save';
    var listUrl = "/userBonus/list";
    var columns = [[{
        field: 'id',
        checkbox: true
    }, {
        field: 'userId',
        title: '用户ID',
        width: "125px",
    }, {
        field: 'bonus',
        title: '奖励说明',
        width: "125px",
        formatter: function (value, row, index) {
            if (value != null) {
                return value.title;
            }
        }
    }, {
        field: 'state',
        title: '状态',
        width: "125px",
        formatter: function (value, row, index) {
            if (value == '1') {
                return '未使用';
            } else if (value == '2') {
                return '已使用';
            } else if (value == '3') {
                return '已过期';
            }
        }
    }, {
        field: 'usePlantfrom',
        title: '使用平台',
        width: "100px",
        formatter: function (value, row, index) {
            var plantform = [];
            plantform["1"] = "PC";
            plantform["2"] = "H5";
            plantform["3"] = "APP";
            var txt = [];
            if (row.bonus.usePlantfrom) {
                var values = row.bonus.usePlantfrom.split(",");
                for (i in values) {
                    txt.push(plantform[values[i]]);
                }
            }
            return txt.join(",");
        }
    }, {
        field: 'getPlantfrom',
        title: '获取平台',
        width: "100px",
        formatter: function (value, row, index) {
            var plantform = [];
            plantform["1"] = "PC";
            plantform["2"] = "H5";
            plantform["3"] = "APP";
            var txt = [];
            if (row.bonus.getPlantfrom) {
                var values = row.bonus.getPlantfrom.split(",");
                for (i in values) {
                    txt.push(plantform[values[i]]);
                }
            }
            return txt.join(",");
        }
    }, {
        field: 'beginTime',
        title: '开始时间',
        width: "125px",
        formatter: function (value, row, index) {
            if (row.bonus != null) {
                return row.bonus.beginTime;
            }
        }
    }, {
        field: 'endTime',
        title: '结束时间',
        width: "125px",
        formatter: function (value, row, index) {
            if (row.bonus != null) {
                return row.bonus.endTime;
            }
        }
    }, {
        field: 'type',
        title: '奖励类型',
        width: "100px",
        formatter: function (value, row, index) {
            if (row.bonus != null) {
                if (row.bonus.type == '1') {
                    return "特权本金";
                } else if (row.bonus.type == '2') {
                    return "加息卷";
                } else if (row.bonus.type == '3') {
                    return "现金卷";
                }

            }
        }
    }, {
        field: 'productType',
        title: '产品类型',
        width: "125px",
        formatter: function (value, row, index) {
            var plantform = [];
            plantform["103"] = "车辆周转袋";
            plantform["104"] = "房产周转贷";
            plantform["105"] = "个人消费贷";
            plantform["106"] = "个体经营贷";
            plantform["107"] = "农业贷";
            plantform["108"] = "企业经营贷";
            var txt = [];
            if (row.bonus.productType) {
                var values = row.bonus.productType.split(",");
                for (i in values) {
                    txt.push(plantform[values[i]]);
                }
            }
            return txt.join(",");
        }
    }, {
        field: 'useTime',
        title: '使用时间',
        width: "125px",
    }, {
        field: 'targetIds',
        title: '标的Id',
        width: "125px",
    }, {
        field: 'orderId',
        title: '订单号',
        width: "125px",
    }, {
        field: 'activityId',
        title: '活动ID',
        width: "125px",
    }]];
    list.init({url: listUrl, columns: columns});
</script>
